<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <li v-for='(book, index) in books'>{{book}}</li>
    <h2>总价格：{{totalPrice}}</h2>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        message: 'Hello',
        books: [
          { id: 110, name: 'Unix', price: 119 },
          { id: 111, name: 'Linx', price: 118 },
          { id: 112, name: 'OS', price: 116 },
          { id: 113, name: 'Http', price: 118 }
        ]
      },
      computed: {
        totalPrice: function () {
          let result = 0;
          for (let i = 0; i < this.books.length; i++) {
            result += this.books[i].price
          }
          return result
        },
      },
      methods: {

      }
    })
  </script>
</body>

</html>